#include <iostream>
#include <string>
// 包含SpireMS SDK头文件
#include <sms_core.h>


int main(int argc, char *argv[])
{
    sms::Client clt("/service1", "std_msgs::String", "std_msgs::String");
    
    while (1)
    {
        nlohmann::json msg = sms::def_msg("std_msgs::String");
        msg["data"] = "hello world!";
        nlohmann::json resp = clt.request(msg);
        if (resp.empty())
            std::cout << "TIMEOUT!" << std::endl;
        else
            std::cout << resp["data"].get<std::string>() << std::endl;
        sms::msleep(1000);
    }

    clt.join();
    return 0;
}

